package com.yyfax.ph.progress.search;

import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yyfax.ph.base.YJPH;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

import java.util.List;

public class ProgressModel extends Model {

	@Override
	public void onNext(Object obj) {
		ProgressResult progressResult = cast(obj);
		EventAgent.post(progressResult);
	}

	@Override
	public Observable getObservable(Object params, int functionalCode) {
		Service service = (Service) NetworkHelper.createService(Service.class);
		String token = YJPH.getInstance().getPreferenceManager().getLoginToken();
		return service.getList(token, (GetListParams) params);

	}

	private interface Service {
		@POST("apply/query/getProgressList")
		Observable<ProgressResult> getList(@Header("token") String token, @Body GetListParams cancel);

	}


	public static class GetListParams {
		/**
		 * 默认全部状态
		 */
		public String status = "0";
		/**
		 * 搜索内容
		 */
		public String section = "";
		/**
		 * 加载第几页
		 */
		public int pageNo = 1;
		/**
		 * 分页大小
		 */
		public int pageSize = 20;
		/**
		 * 排序
		 */
		public String sortType = "desc";
	}


	public static class ProgressResult extends BaseResultEntity<List<ProgressBean>> {
	}

	public static class ProgressBean {
		public String referDate;
		public String referPhone;
		public String status;
		public String rcmdName;
		public boolean highMark;
		public String taskNo;
		public String avatar;
		public String statusType;

	}

}
